<template>
  <div>
    <pre style="white-space: pre-wrap;">{{ bookContent }}</pre>
  </div>
</template>
<script>
import axios from "axios";
export default {
  name: 'Article',
  props: {
    content: {
      type: String,
      required: true
    }
  },
  data() {
    return {
      bookPath:'',
      bookContent:null
    };
  },
  methods: {
    getArticle() {
      let _this = this;
      // 使用 axios 将登录信息发送到后端
      if (sessionStorage.getItem("bookPath")!==null){
        _this.bookPath = sessionStorage.getItem("bookPath")
        axios({
          url: _this.bookPath,              // 请求地址
          method: "get",                       // 请求方法
          headers: {                            // 请求头
            "Content-Type": "application/json",
          },
        }).then((resBook) => {
          if (resBook.data !== null) {
            _this.bookContent = resBook.data;
          } else {
            alert("没有收到文章数据")
          }
        });
      }else {
        alert("找不到对应的文章吗，将返回首页！")
        this.$router.push("/containerPage")
      }



    },
  },
  mounted() {
    this.getArticle();

  },
};
</script>
<style scoped>
</style>
